<?php
function view_bckhome($config,$param) {
    $db = new db($config);
	$desc = $db->query("SELECT * FROM deskripsi WHERE page ='home'");
    $param['kutipan'] = true;
    $param['loggedin'] = true;
    view_backend_header($config, $param);
    //verifikasi isian gunakan javascript
    if (isset($_SESSION['editted'])) {
        echo '<div class="alert alert-warning">'.$_SESSION['editted'].'</div>';
        unset($_SESSION['editted']);
    }
    ?>
	<div>
        <form method="post" action="<?php echo $config['home_url']."backend/edhome"?>">
            <div>Deskripsi : <textarea class="descbck" name="deschome"><?php echo $desc[0]['deskripsi']; ?></textarea>
            <div><input class="btn" type="submit" value="Ubah" name="ubah" /></div>
        </form>
    </div>
    <h3 onclick="javascript:showHide('foto');">Kutipan++</h3>
	<div id="foto" style="display:none">
		<form action="<?php echo $config['home_url']."backend/edkutip"?>" method="post" enctype="multipart/form-data">
			<div>Gambar : <input type='file' name='gambar'/></div>
			<div><input class="btn" type="submit" value="Tambah" name="tambah" /></div>
		</form>
		<div><?php
			$uploaddir = $config['image_path'].'home'.DIRECTORY_SEPARATOR;
			$limitedext = array("jpg","jpeg","png","bmp");
			$cfiles = 0;
			$files = scandir($uploaddir.'pre'.DIRECTORY_SEPARATOR);
			for($i = 0; $i < count($files); $i++) {
				$file = $files[$i];
				$getExt = explode('.',$file);
				$file_ext = $getExt[count($getExt)-1];
				if (in_array($file_ext,$limitedext)) {
					?>
					<div style="float:left">
						<div class='gallery-thumb' id='gallery-thumb-<?php echo $cfiles; ?>' style='max-width:120px;max-height:50px;overflow:hidden;'>
							<img id="gallery-thumb-img-<?php echo $cfiles; ?>" src="<?php echo $config['image_url']."home/pre/".$file; ?>" alt="<?php echo $file; ?>" /></a>
						</div>
						<div align="center">
							<div><a class="ahapus" href="<?php echo $config['home_url']."backend/delkutip?img=$file"?>">(X)</a></div>
						</div>
					</div>
					<?php
					$cfiles++;
				}
			}
			if ($cfiles<1){
				echo '<div class="judul-gale"><h4>Tidak terdapat kutipan saat ini</h4></div>';
			}?>
			<div style="clear:both"></div>
		</div>
	</div>
    <?php
    view_backend_footer($config, $param);
}
